import { defineStore } from 'pinia'
import { ref } from 'vue'

export const useUserStore = defineStore(
  'user',
  () => {
    // 用户信息
    const userInfo = ref({})

    const setUserInfo = value => {
      userInfo.value = value
    }

    // 获取token
    const getToken = () => {
      return userInfo.value.token
    }

    return {
      userInfo,
      setUserInfo,
      getToken
    }
  },
  { persist: true }
)
